import {
  BwComPropSetConstValueComEnum,
  BwCustomComPropDataTypeEnum,
  BwCustomComEmitParamDataTypeEnum,
  BwCustomComSoltTypeEnum,
} from '../../../render/models'
import type {
  BwCustomComEmitInfoModel,
  BwCustomComSlotInfoModel,
  BwCustomComPropInfoModel,
} from '../../../render/models'

/** 组件属性 */
const comAttrs: Array<BwCustomComPropInfoModel> = [
  {
    key: 'class',
    name: 'classNames',
    isRequire: false,
    defaultValue: undefined,
    dataType: [
      BwCustomComPropDataTypeEnum.string,
      BwCustomComPropDataTypeEnum.array,
    ],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'autofocus',
    name: '自动获取焦点',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'bordered',
    name: '是否有边框',
    isRequire: false,
    defaultValue: 'true',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'controls',
    name: '是否显示增减按钮',
    isRequire: false,
    defaultValue: 'true',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'decimalSeparator',
    name: '小数点',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'defaultValue',
    name: '初始值',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.number],
    defaultValueDataType: BwCustomComPropDataTypeEnum.number,
    constValueSetCom: BwComPropSetConstValueComEnum.number,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'disabled',
    name: '禁用',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  // {
  //   key: 'formatter',
  //   name: '展示值的格式',
  //   isRequire: false,
  //   defaultValue: undefined,
  //   dataType: [BwCustomComPropDataTypeEnum.function],
  //   defaultValueDataType: BwCustomComPropDataTypeEnum.function,
  //   constValueSetCom: BwComPropSetConstValueComEnum.switch,
  //   constValueSetComProps: null,
  //   remark: '',
  // },
  {
    key: 'keyboard',
    name: '是否启用键盘快捷行为',
    isRequire: false,
    defaultValue: 'true',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'max',
    name: '最大值',
    isRequire: false,
    defaultValue: 'Infinity',
    dataType: [BwCustomComPropDataTypeEnum.number],
    defaultValueDataType: BwCustomComPropDataTypeEnum.number,
    constValueSetCom: BwComPropSetConstValueComEnum.number,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'min',
    name: '最小值',
    isRequire: false,
    defaultValue: '-Infinity',
    dataType: [BwCustomComPropDataTypeEnum.number],
    defaultValueDataType: BwCustomComPropDataTypeEnum.number,
    constValueSetCom: BwComPropSetConstValueComEnum.number,
    constValueSetComProps: null,
    remark: '',
  },
  // {
  //   key: 'parser',
  //   name: '从 formatter 里转换回数字的方式',
  //   isRequire: false,
  //   defaultValue: undefined,
  //   dataType: [BwCustomComPropDataTypeEnum.function],
  //   defaultValueDataType: BwCustomComPropDataTypeEnum.function,
  //   constValueSetCom: BwComPropSetConstValueComEnum.function,
  //   constValueSetComProps: null,
  //   remark: '',
  // },
  {
    key: 'precision',
    name: '数值精度',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.number],
    defaultValueDataType: BwCustomComPropDataTypeEnum.number,
    constValueSetCom: BwComPropSetConstValueComEnum.number,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'size',
    name: '控件大小',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.select,
    constValueSetComProps: JSON.stringify({
      options: [
        {
          label: '大',
          value: 'large',
        },
        {
          label: '中',
          value: 'middle',
        },
        {
          label: '小',
          value: 'small',
        },
      ],
    }),
    remark: '',
  },
  {
    key: 'status',
    name: '设置校验状态',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.select,
    constValueSetComProps: JSON.stringify({
      options: [
        {
          label: '错误',
          value: 'error',
        },
        {
          label: '警告',
          value: 'warning',
        },
      ],
    }),
    remark: '',
  },
  {
    key: 'step',
    name: '每次改变步数',
    isRequire: false,
    defaultValue: '1',
    dataType: [
      BwCustomComPropDataTypeEnum.number,
      BwCustomComPropDataTypeEnum.string,
    ],
    defaultValueDataType: BwCustomComPropDataTypeEnum.number,
    constValueSetCom: BwComPropSetConstValueComEnum.number,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'stringMode',
    name: '字符值模式',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'placeholder',
    name: '输入提示文案',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },

  {
    key: 'value',
    name: 'value(v-model)',
    isModel: true,
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.number],
    defaultValueDataType: BwCustomComPropDataTypeEnum.number,
    constValueSetCom: BwComPropSetConstValueComEnum.number,
    constValueSetComProps: null,
    remark: '',
  },
]

/** 组件事件 */
const comEmits: Array<BwCustomComEmitInfoModel> = [
  {
    key: 'update:value',
    name: '绑定Value',
    isModel: true,
    params: [
      {
        paramKey: 'value',
        paramName: '绑定值',
        paramDataType: BwCustomComEmitParamDataTypeEnum.number,
        remark: '',
      },
    ],
  },
  {
    key: 'change',
    name: '输入框内容变化时的回调',
    params: [
      {
        paramKey: 'value',
        paramName: '值',
        paramDataType: BwCustomComEmitParamDataTypeEnum.number,
        remark: '',
      },
    ],
  },
  {
    key: 'pressEnter',
    name: '按下回车的回调',
    params: [
      {
        paramKey: 'e',
        paramName: 'e',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
  {
    key: 'step',
    name: '点击上下箭头的回调',
    params: [
      {
        paramKey: 'value',
        paramName: '值',
        paramDataType: BwCustomComEmitParamDataTypeEnum.number,
        remark: '',
      },
      {
        paramKey: 'info',
        paramName: 'info',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
]

/** 组件插槽 */
const comSlots: Array<BwCustomComSlotInfoModel> = [
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'addonAfter',
      slotName: '后置标签',
    },
  },
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'addonBefore',
      slotName: '前置标签',
    },
  },
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'prefix',
      slotName: '前缀图标插槽',
    },
  },
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'upIcon',
      slotName: '上箭头图标插槽',
    },
  },
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'downIcon',
      slotName: '下箭头图标插槽',
    },
  },
]

export const antNumberInfo = {
  comAttrs,
  comEmits,
  comSlots,
}
